import httpFetch from 'share/httpFetch';
import errorMessage from 'share/errorMessage';

export default {
  // 获取费用发票映射规则列表
  getMappingRuleList(params) {
    return httpFetch.get(`/api/exp/receipt/mapping`, params)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      })
  },

  // 新建/修改发票映射规则
  updateMappingRule(params) {
    return httpFetch.post(`/api/exp/receipt/mapping`, params)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      })
  },

  // 获取费用发票映射规则详情
  getMappingRuleDetail(id) {
    return httpFetch.get(`/api/exp/receipt/mapping/${id}`)
  },

  // 获取发票黑白名单列表
  getWhiteBlackList(params) {
    return httpFetch.get(`/api/exp/receipt/mapping/list`, params)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      })
  },

  // 获取黑白名单编码
  getWhiteBlackCode() {
    return httpFetch.get(`/api/exp/receipt/mapping/list/code`)
  },

  // 新建/修改黑白名单配置
  updateWhiteBlackDetail(params) {
    return httpFetch.post(`/api/exp/receipt/mapping/list`, params)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      })
  },

  // 删除黑白名单配置
  deleteWhiteBlackItem(id) {
    return httpFetch.delete(`/api/exp/receipt/mapping/list/${id}`)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      })
  },

  // 获取映射规则下的规则项
  getMappingItemList(params) {
    return httpFetch.get(`/api/exp/receipt/mapping/item`, params)
  },

  // 新建/修改映射规则下的规则项
  updateMappingItem(params) {
    return httpFetch.post(`/api/exp/receipt/mapping/item`, params)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      })
  },

  // 批量删除映射规则下的规则项
  batchDeleteMappingItem(params, ids) {
    params.expReceiptMappingItemIdList = ids;
    return httpFetch.delete(`/api/exp/receipt/mapping/item/batch/delete`, params)
  },

  // 批量启用/禁用映射规则下的规则项
  batchUpdateMappingItem(params, ids) {
    params.expReceiptMappingItemIdList = ids;
    return httpFetch.put(`/api/exp/receipt/mapping/item/enable`, params)
  },

  // 查询黑白名单发票类型配置
  getReceiptList(params) {
    return httpFetch.get(`/api/exp/receipt/mapping/list/receipt`, params)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      })
  },

  // 启用/禁用黑白名单发票类型
  updateReceiptEnable(params) {
    return httpFetch.put(`/api/exp/receipt/mapping/list/receipt/enable`, params)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      })
  },

  // 查询黑白名单税务编码配置
  getTaxCodeList(params) {
    return httpFetch.get(`/api/exp/receipt/mapping/list/taxCode`, params)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      })
  },

  // 黑白名单批量添加税务编码
  batchAddTaxCode(params) {
    return httpFetch.post(`/api/exp/receipt/mapping/list/taxCode`, params)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      })
  },

  // 启用/禁用黑白名单税务编码
  updateTaxCodeEnable(params) {
    return httpFetch.put(`/api/exp/receipt/mapping/list/taxCode/enable`, params)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      })
  },
}
